import axios from 'axios';
import fitUniapp from "./fit-uniapp.js";
import requestConfig from './request-interceptor.js';
import responseConfig from './response-interceptor.js';
import { HTTP_CONFIG } from "@config/index.js";
// 使用自定义适配器，适配uniapp
fitUniapp(axios);
// 配置默认接口
const service = axios.create({
    baseURL: HTTP_CONFIG.API_HOST,
    timeout: 6000
});

// 请求拦截
service.interceptors.request.use(requestConfig().config, requestConfig().error);

// 响应拦截
service.interceptors.response.use(responseConfig().config, responseConfig().error);

export default service;